package CustomClasses;

import javafx.event.EventHandler;
import javafx.scene.Cursor;
import javafx.scene.control.Label;
import javafx.scene.effect.BlurType;
import javafx.scene.effect.DropShadow;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import View.Map;

public class CustomConnection {

	String from;
	String to;
	Integer id;
	Integer distance;
	Label label;
	Boolean customDistance;
	Boolean disable = false;

	public CustomConnection(Integer id, String from, String to, Integer distance, Boolean customDistance) {
		this.id = id;
		this.from = from;
		this.to = to;
		this.distance = distance;
		this.customDistance = customDistance;
	}

	public Boolean getDisable() {
		return disable;
	}

	public void setDisable(Boolean disable) {
		this.disable = disable;
	}

	public CustomConnection() {
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getTo() {
		return to;
	}

	public void setTo(String to) {
		this.to = to;
	}

	public Integer getDistance() {
		return distance;
	}

	public void setDistance(Integer distance) {
		this.distance = distance;
	}

	public Label getLabel() {
		final Label label = new Label();

		DropShadow ds = new DropShadow();
		ds.setOffsetY(0.0);
		ds.setOffsetX(0.0);
		ds.setRadius(20);
		ds.setBlurType(BlurType.GAUSSIAN);
		ds.setSpread(0.8);
		ds.setColor(Color.BLACK);
		label.setEffect(ds);
		label.setId("label" + id);
		label.setCursor(Cursor.HAND);
		label.setLayoutX(50);
		label.setLayoutY(50);
		if (Map.selectConnection.getValue().equals(label.getId())) {
			label.setTextFill(Color.ORANGE);
		} else {
			label.setTextFill(Color.WHITE);
		}
		label.setOnMouseClicked(new EventHandler<MouseEvent>() {
			@Override
			public void handle(MouseEvent mouse) {
				if (Map.selectConnection.getValue().equals(label.getId())) {
					Map.selectConnection.setValue("");
				} else {
					Map.selectConnection.setValue(label.getId());
				}
			}
		});

		return label;
	}

	public void setLabel(Label label) {
		this.label = label;
	}

	public Boolean getCustomDistance() {
		return customDistance;
	}

	public void setCustomDistance(Boolean customDistance) {
		this.customDistance = customDistance;
	}

}
